<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <div v-mysty="cssMsg">我想去桂林</div>
        <input type="text" v-focus>
        <div>{{money}}</div>
        <div>
            ￥{{chineseMon}}
        </div>
    </div>
</body>
<script>
    Vue.directive('mysty',{
        bind:function(el,sty){
            console.log(el);
            console.log(sty.value);
            el.style.background = sty.value.bg;
            el.style.color = sty.value.ftcolor;
        }
    })
    new Vue({
        el:'#app',
        data:{
            cssMsg:{
                bg:'green',
                ftcolor:'#fff'
            },
            chineseMon: 17
        },
        directives:{ // 局部指令（+s）
            mysty:{
                bind:function(el,sty){
                    console.log(el);
                    console.log(sty.value);
                    el.style.background = sty.value.bg;
                    el.style.color = sty.value.ftcolor;
                }
            },
            focus:{
                inserted:function(el){
                    el.focus();
                }
            }
        },
        computed: { // 计算属性
            money:function(){
                return '￥'+this.chineseMon
            }
        },
    })
</script>
</html>